from rest_framework import serializers
from .models import Area


class ProvincePlaceSerializer(serializers.ModelSerializer):
    """省级区划序列化器"""
    class Meta:
        model =Area
        fields = ("id", "name")


class AreaSerializer(serializers.ModelSerializer):
    """获取区划及其下级序列化器"""
    subs = ProvincePlaceSerializer(many=True)

    class Meta:
        model = Area
        fields = ("id", "name", "subs")